﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace FrameworkQ.ObjectSpace.Util
{
    public class ConcretePopulator : IPopulateObject
    {
        private Type _type = null;
        private ConcretePopulatorDelegate _populateObject = null;

        public ConcretePopulator(Type type, string methodName)
        {
            MethodInfo method = type.GetMethod(methodName, BindingFlags.Static);
            _populateObject = (ConcretePopulatorDelegate)Delegate.CreateDelegate(typeof(ConcretePopulatorDelegate), method);
        }

        public void PopulateObject(object obj, System.Data.IDataReader reader)
        {
            throw new NotImplementedException();
        }


        public object PopulateObject(System.Data.IDataReader reader)
        {
            if (_populateObject != null)
            {
                return _populateObject(reader);
            }
            return null;
        }

        public bool RequiresObjectCreation
        {
            get { return false; }
        }
    }
}
